<!DOCTYPE html>
<html lang="en"	xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>在线考试系统后台试题卷管理页面</title>
    <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no' name='viewport' />
    <link rel="stylesheet" href="assets/css/bootstrap.min.css" th:href="@{/webjars/bootstrap/4.0.0/css/bootstrap.css}">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i">
    <link rel="stylesheet" href="assets/css/ready.css" th:href="@{/assets/css/ready.css}">
    <link rel="stylesheet" href="assets/css/demo.css" th:href="@{/assets/css/demo.css}">
</head>
<body>
<div class="wrapper">
    <!--header-->
    <div th:replace="commons/bar::header"></div>

    <!--slidebar-->
    <div th:replace="commons/bar::#sidebar(activeUri='/paper/getAllPaper')"></div>

    <!--main panel-->
    <div class="main-panel">
        <div class="content">
            <div class="container-fluid">
                <h4 class="page-title">试卷管理页面</h4>
                <div class="row">
                    <div class="col-md-2"><h2><a class="btn btn-primary" href="#" th:href="@{/paper/toAddPaper}">试卷添加</a></h2> </div>
                    <div class="col-md-12">
                        <div class="card">
                            <div class="card-body">
                                <table class="table table-head-bg-primary">
                                    <thead>
                                    <tr>
                                        <th scope="col">#</th>
                                        <th scope="col">试卷名字</th>
                                        <th scope="col">单选题分数</th>
                                        <th scope="col">多选题分数</th>
                                        <th scope="col">判断题分数</th>
                                        <th scope="col">操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr th:each="pap,papStat:${papers}">
                                        <td th:text="${papStat.count}"></td>
                                        <td th:text="${#strings.abbreviate(pap.getPaperName(),10)}"></td>
                                        <td th:text="${pap.getScoreSin()}"></td>
                                        <td th:text="${pap.getScoreChe()}"></td>
                                        <td th:text="${pap.getScoreJug()}"></td>
                                        <td>
                                            <a class="btn btn-sm btn-info" th:href="@{/paper/toEditPaper/}+${pap.paperId}">编辑</a>
                                            <button th:attr="del_uri=@{/paper/deletePaper/}+${pap.paperId}" class="btn btn-sm btn-danger deleteBtn">删除</button>
                                            <a class="btn btn-sm btn-primary " th:href="@{/paper/toManagerQuestion/}+${pap.paperId}">管理试题</a>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--footer-->
        <div th:replace="commons/bar::footer"></div>
</div>
</div>
//删除表单
<form id="deleteClasseForm" method="post">
    <input type="hidden" name="_method" value="delete">
</form>
<!--映入jclary，src-->
<script src="assets/js/core/jquery.3.2.1.min.js" th:src="@{/webjars/jquery/3.2.1/jquery.js}"></script>
<script th:src="@{/webjars/layer/src/layer.js}"></script>
<script>
    //删除指定id试题
    $(".deleteBtn").click(function () {
        //获取uri
        // $(this).attr("del_uri")
        //提交表单
        // $("#deleteClasseForm").attr("action",$(this).attr("del_uri")).submit();
        if(confirm("确实要删除吗？")){
            //提交表单
            $("#deleteClasseForm").attr("action",$(this).attr("del_uri")).submit();
            layer.msg("删除成功", {time:2000, icon:6});
        }else {
            layer.msg("删除取消", {time:2000, icon:5, shift:6});
        }
        return false;
    });

</script>
</body>
</html>